#!/usr/bin/python
# -*- coding: utf-8 -*-

import Ice, IceGrid, IceStorm
import sys, os

try:
    HOME = os.environ['ROBOTS']
except KeyError:
    print 'ROBOTS environment variable is not currently defined.'
    sys.exit(0)

SLICE = os.path.join(HOME, 'slice')
FILE = os.path.join(SLICE, 'Robots.ice')
Ice.loadSlice('--all -I/usr/share/slice', ['-I' + SLICE, FILE])

NUMBER = 6
DELAY = 2

import Robots

class AMI_Model_beginI (object):

    def ice_response (self):
        pass

    def ice_exception (self, ex):
        pass

class Client (Ice.Application):

    def run (self, argv):

        prxs = []

        names = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']

        auctioneer = Robots.AuctioneerPrx.uncheckedCast(
            self.communicator().stringToProxy('Auctioneer -t:tcp -h 127.0.0.1 -p 9898'))

        team = Robots.AgentTeamPrx.uncheckedCast(
            self.communicator().stringToProxy('AgentTeam.1 -t:tcp -h 127.0.0.1 -p 9898'))

        prxs = team.create(['1', '2', '3', '4', '5', '6'])
        for prx in prxs:
            prx.ice_ping()

        print 'OK.'

        auctioneer.begin_async(AMI_Model_beginI())

        return 0

Client().main(sys.argv, os.path.join(HOME, 'config', 'config.client'))
